//
//  TabBarController.m
//  MONO
//
//  Created by qianfeng on 15/11/3.
//  Copyright © 2015年 qianfeng. All rights reserved.
//

#import "TabBarController.h"

@interface TabBarController ()

@end

@implementation TabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIViewController * relationship = [[UIStoryboard storyboardWithName:@"Relationship" bundle:nil] instantiateViewControllerWithIdentifier:@"Relationship"];
    [self setItemWithViewController:relationship title:@"关系管理" image:@"tab_icon_grey_guanxiguanli" selectedImage:@"tab_icon_red_guanxiguanli"];
    
    UIViewController * gift = [[UIStoryboard storyboardWithName:@"Gift" bundle:nil] instantiateViewControllerWithIdentifier:@"Gift"];
    [self setItemWithViewController:gift title:@"情礼攻略" image:@"tab_icon_grey_qingligonglve" selectedImage:@"tab_icon_red_qingligonglve"];
    
    UIViewController * find = [[UIStoryboard storyboardWithName:@"Find" bundle:nil] instantiateViewControllerWithIdentifier:@"Find"];
    [self setItemWithViewController:find title:@"发现" image:@"tab_icon_grey_faxian" selectedImage:@"tab_icon_red_faxian"];
    
    UIViewController * mine = [[UIStoryboard storyboardWithName:@"Mine" bundle:nil] instantiateViewControllerWithIdentifier:@"Mine"];
    [self setItemWithViewController:mine title:@"我的" image:@"tab_icon_grey_wode" selectedImage:@"tab_icon_red_wode"];
}

- (void)setItemWithViewController:(UIViewController *)controller title:(NSString *)title image:(NSString *)imageName selectedImage:(NSString *)selectImageName{
    
    controller.navigationItem.title = title;
    controller.tabBarItem.title = title;
    controller.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    controller.tabBarItem.selectedImage = [[UIImage imageNamed:selectImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    NSDictionary * attributes = @{NSForegroundColorAttributeName:[UIColor colorWithRed:1 green:0 blue:0 alpha:1.000]};
    [controller.tabBarItem setTitleTextAttributes:attributes forState:UIControlStateSelected];
    
    [self addChildViewController:controller];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
